const vmAMap = weex.requireModule('vmAMap')

vmAMap.initAmap('09fb311b956ff9bf8bc5e2de5bdacd8d')

const AMap = Object.create(null)
AMap.install = (Vue, options) => {
    Vue.prototype.$amap = {
        getLocationOnce() {
            return new Promise((resolve, reject) => {
                vmAMap.getLocationOnce({}, ({ status, errorMsg, data }) => {
                    status === 0 ? resolve(data) : reject({ status, errorMsg, data })
                })
            })
        },
        getLocation() {
            return new Promise((resolve, reject) => {
                vmAMap.getLocation({}, ({ status, errorMsg, data }) => {
                    status === 0 ? resolve(data) : reject({ status, errorMsg, data })
                })
            })
        }
    }
}

Vue.use(AMap)
